<div class='head'>
  <div class='title'>  
    <h1>会员管理</h1>
  </div>
  <div class='tools'>
    <div class="type">
      <% form_tag '#', :id => 'search_type_form' do  %>      
        <div>
          <%= text_field_tag 'key_word', params[:key_word], :title => '昵称、手机、email' %>      
        </div>      
        <div>          
        <%= check_box_tag :high_star, 'high',params[:high_star].present? , :class => :no%><%= label_tag 'high_star',image_tag('tools/star_on.png'),:title => '已添加星标', :class => :high %>
        <%= check_box_tag :low_star, 'low',params[:low_star].present?, :class => :no %><%= label_tag 'low_star',image_tag('tools/star_off.png'),:title => '未添加星标', :class => :low %>
        <%= radio_button_tag :search_type,'all',params[:search_type] == 'all',:id => 'search_type_all', :class => :no %><%= label_tag 'search_type_all','全部' %>
        <%= radio_button_tag :search_type,'sm_exception',params[:search_type] == 'sm_exception',:id => 'search_type_sm_exception', :class => :no %><%= label_tag 'search_type_sm_exception','短信异常',:title => '昨日短信异常' %>
        <%= hidden_field_tag 'sm_exception', params[:sm_exception] %>
        <% if params.sm_exception_users? %>
        <span title="<%= h params[:sm_exception] %>">
          <%= link_to_function h(truncate(params[:sm_exception].present? ? "#{params[:sm_exception]}▼" : '全部▼', :length => 20)),
                "
                  if($('sm_exceptions').style.display == '') {
                    $('sm_exceptions').hide();
                  } else {
                    $('sm_exceptions').show();
                  }
                ",
                :title => h(params[:sm_exception].present? ? params[:sm_exception] : '全部')               
             %>     
          <div id="sm_exceptions" style='display:none;'>
          <div>
            <%= link_to_function '全部',
                  "$('sm_exception').value = '';$('sm_exceptions').hide()",
                  :class => "sm_exception #{params[:sm_exception].blank? ? 'h' : ''}"
             %>
          </div>
        <% @sm_exceptions.each do |sm|  %>
          <% if sm.exception.present? %>
          <div>
            <%= link_to_function truncate(sm.exception, :length => 20),
                  "$('sm_exception').value = \"#{sm.exception}\";$('sm_exceptions').hide()",
                  :class => "sm_exception #{sm.exception == params[:sm_exception] ? 'h' : ''}",
                  :title => h(sm.exception)
             %>
          </div>
          <% end  %>
        <% end if @sm_exceptions.present? %>  
        </div>               
        </span>
        <% end %>        
        </div>
      <% end %>
    </div>
    <div id='for_fetion_version'>
      <div id='fetion_versions'>
        <%= link_to_function( "全部版本",
          "by_fetion_version('all')",
          :class => params[:fetion_version] == 'all' ? 'h fetion_version' : 'fetion_version'  ,
          :title => '所有版本'
        ) %>
        <%= link_to_function( "▶ lite",
          "by_fetion_version('lite')",
          :class => params[:fetion_version] == 'lite' ? 'h fetion_version' : 'fetion_version'  ,
          :title => 'lite'
        ) %>
        <%= link_to_function( "  no_mobile",
          "by_fetion_version('lite_no_mobile')",
          :class => params[:fetion_version] == 'lite_no_mobile' ? 'h fetion_version' : 'fetion_version'  ,
          :title => 'lite版无手机号'
        ) %>
        <%= link_to_function( "  mobile",
          "by_fetion_version('lite_mobile')",
          :class => params[:fetion_version] == 'lite_mobile' ? 'h fetion_version' : 'fetion_version'  ,
          :title => 'lite版有手机号'
        ) %>
        <%= link_to_function( "  wait",
          "by_fetion_version('lite_mobile_wait')",
          :class => params[:fetion_version] == 'lite_mobile_wait' ? 'h fetion_version' : 'fetion_version'  ,
          :title => 'lite版wait'
        ) %>
        <%= link_to_function( "  success",
          "by_fetion_version('lite_mobile_success')",
          :class => params[:fetion_version] == 'lite_mobile_success' ? 'h fetion_version' : 'fetion_version'  ,
          :title => 'lite版success'
        ) %>
        <%= link_to_function( "▶ maple20",
          "by_fetion_version('maple20')",
          :class => params[:fetion_version] == 'maple20' ? 'h fetion_version' : 'fetion_version'  ,
          :title => 'maple20'
        ) %>
        <%= link_to_function( "  no_mobile",
          "by_fetion_version('maple20_no_mobile')",
          :class => params[:fetion_version] == 'maple20_no_mobile' ? 'h fetion_version' : 'fetion_version'  ,
          :title => 'maple20版无手机号'
        ) %>
        <%= link_to_function( "  mobile",
          "by_fetion_version('maple20_mobile')",
          :class => params[:fetion_version] == 'maple20_mobile' ? 'h fetion_version' : 'fetion_version'  ,
          :title => 'maple20版有手机号'
        ) %>             
      </div> 
    </div>      
    <div id='order_bys'>
      <div class="order_by">
      <%= link_to_function( "注册时间↑",
            "order_by('created_at','desc')",
            :class => params.order_by == 'users.created_at asc' ? 'order_by h' : 'order_by' ,
            :title => '升序排序'
          ) if params.order_by == 'users.created_at asc' or  params[:order] != 'created_at' %>
      <%= link_to_function( "注册时间↓",
            "order_by('created_at','asc')",
            :class => params.order_by == 'users.created_at desc' ? 'order_by h' : 'order_by' ,
            :title => '降序排序'
          )  if params.order_by == 'users.created_at desc' %>
      <%= link_to_function( "登录时间↑",
            "order_by('login_at','desc')",
            :class => params.order_by == 'users.login_at asc' ? 'order_by h' : 'order_by' ,
            :title => '升序排序'
          ) if params.order_by == 'users.login_at asc' or  params[:order] != 'login_at' %>
      <%= link_to_function( "登录时间↓",
            "order_by('login_at','asc')",
            :class => params.order_by == 'users.login_at desc' ? 'order_by h' : 'order_by' ,
            :title => '降序排序'
          )  if params.order_by == 'users.login_at desc' %>
      <%= link_to_function( "绑定时间↑",
            "order_by('binded_at','desc')",
            :class => params.order_by == 'users.binded_at asc' ? 'order_by h' : 'order_by' ,
            :title => '升序排序'
          ) if params.order_by == 'users.binded_at asc' or  params[:order] != 'binded_at' %>
      <%= link_to_function( "绑定时间↓",
            "order_by('binded_at','asc')",
            :class => params.order_by == 'users.binded_at desc' ? 'order_by h' : 'order_by' ,
            :title => '降序排序'
          )  if params.order_by == 'users.binded_at desc' %>
      <%= link_to_function( "吐司片数↑",
            "order_by('user_tool_settings_count','desc')",
            :class => params.order_by == 'users.user_tool_settings_count asc' ? 'order_by h' : 'order_by' ,
            :title => '升序排序'
          ) if params.order_by == 'users.user_tool_settings_count asc' or  params[:order] != 'user_tool_settings_count' %>
      <%= link_to_function( "吐司片数↓",
            "order_by('user_tool_settings_count','asc')",
            :class => params.order_by == 'users.user_tool_settings_count desc' ? 'order_by h' : 'order_by' ,
            :title => '降序排序'
          )  if params.order_by == 'users.user_tool_settings_count desc' %>
      <%= link_to_function( "邮件封数↑",
            "order_by('emails_count','desc')",
            :class => params.order_by == 'users.emails_count asc' ? 'order_by h' : 'order_by' ,
            :title => '升序排序'
          ) if params.order_by == 'users.emails_count asc' or  params[:order] != 'emails_count' %>
      <%= link_to_function( "邮件封数↓",
            "order_by('emails_count','asc')",
            :class => params.order_by == 'users.emails_count desc' ? 'order_by h' : 'order_by' ,
            :title => '降序排序'
          )  if params.order_by == 'users.emails_count desc' %>
      <%= link_to_function( "短信条数↑",
            "order_by('sms_count','desc')",
            :class => params.order_by == 'users.sms_count asc' ? 'order_by h' : 'order_by' ,
            :title => '升序排序'
          ) if params.order_by == 'users.sms_count asc' or  params[:order] != 'sms_count' %>
      <%= link_to_function( "短信条数↓",
            "order_by('sms_count','asc')",
            :class => params.order_by == 'users.sms_count desc' ? 'order_by h' : 'order_by' ,
            :title => '降序排序'
          )  if params.order_by == 'users.sms_count desc' %>
    </div>
    </div>
  </div>
</div>
<div class='users'>
  <div class='tip'>
    <div class='info'>
      <% if params.all_users? %>
      共<b><%= @users.total_entries %></b>名会员，其中<b><%= @mobiles_count %></b>名绑定了手机<%= "，占<b>#{@present}%</b>" if @users.total_entries > 0 %>。
      <% elsif params.sm_exception_users? %>
      共<b><%= @users.total_entries %></b>名会员昨日截止到目前<%= params[:sm_exception].blank? ? '接收短信异常' : "因<b title=\"#{h params[:sm_exception]}\">#{h truncate(params[:sm_exception],:length => 20)}</b>无法接收短信" %>，占<b><%= @present %>%</b>。
      <% end %>
    </div>
    <div class='will_paginate'>
      <%= remote_will_paginate @users %>
    </div>    
  </div>
  <% @users.each do |user| %>
    <%= render :partial => 'detail_in_index.html', :locals => { :user => user } %>
  <% end %>  
  <div class='tip bottom'>
    <div class='info'>
      <% if params.all_users? %>
      共<b><%= @users.total_entries %></b>名会员，其中<b><%= @mobiles_count %></b>名绑定了手机<%= "，占<b>#{@present}%</b>" if @users.total_entries > 0 %>。
      <% elsif params.sm_exception_users? %>
      共<b><%= @users.total_entries %></b>名会员昨日截止到目前<%= params[:sm_exception].blank? ? '接收短信异常' : "因<b title=\"#{h params[:sm_exception]}\">#{h truncate(params[:sm_exception],:length => 20)}</b>无法接收短信" %>。
      <% end %>
    </div>
    <div class='will_paginate'>
      <%= remote_will_paginate @users %>
    </div>
  </div>
</div>
<%= observe_form :search_type_form,
      :function => "searching()",
      :frequency => 5
  %>